package demoMod.nanaki.cards.nanaki;

import com.megacrit.cardcrawl.actions.common.ApplyPowerAction;
import com.megacrit.cardcrawl.actions.defect.IncreaseMiscAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.localization.CardStrings;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.powers.watcher.VigorPower;
import demoMod.nanaki.NanakiMod;

public class ConcentratedSpirit extends AbstractNanakiCard {
    public static final String ID = NanakiMod.makeID("ConcentratedSpirit");

    private static final CardStrings cardStrings = CardCrawlGame.languagePack.getCardStrings(ID);
    public static final String NAME = cardStrings.NAME;
    public static final String DESCRIPTION = cardStrings.DESCRIPTION;
    public static final String IMG_PATH = "cards/ConcentratedSpirit";

    private static final CardType TYPE = CardType.SKILL;
    private static final CardRarity RARITY = CardRarity.UNCOMMON;
    private static final CardTarget TARGET = CardTarget.SELF;

    private static final int COST = 0;

    public ConcentratedSpirit() {
        super(ID, NAME, NanakiMod.getResourcePath(IMG_PATH), COST, DESCRIPTION, TYPE, RARITY, TARGET);
        this.baseMagicNumber = this.magicNumber = 1;
        this.misc = 2;
        this.exhaust = true;
    }

    @Override
    public Runnable getUpgradeAction() {
        return () -> {
            upgradeMagicNumber(1);
            this.misc += 1;
        };
    }

    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {
        if (!p.drawPile.isEmpty()) {
            AbstractCard topCard = p.drawPile.getTopCard();
            if (topCard.type == CardType.ATTACK) {
                addToBot(new IncreaseMiscAction(this.uuid, this.misc, this.magicNumber));
            }
        }
        addToBot(new ApplyPowerAction(p, p, new VigorPower(p, this.misc)));
    }
}
